# -*- coding: utf-8 -*-
# @Create_time   : :
# @Author        :kumiler
# @emial         :lukunming@jtexpress.com
# @File          :.py
# @Desc          : 每日读取ods T-1 数据，关联网点维表获取网点其他信息作为补充 ，写入dim 维表

from datetime import timedelta
from spmi.ods.mysql.spmi.piece_sign_network_empty_config import spmi_ods__piece_sign_network_empty_config
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from spmi.dim.spmi.jms_dim_network_whole_massage_check import jms_dim__dim_network_whole_massage_check

spmi_dim__dim_piece_sign_network_empty_config_base = SparkSqlOperator(
    task_id='spmi_dim__dim_piece_sign_network_empty_config_base',
    email=['lukunming@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    master='yarn',
    name='spmi_dim__dim_piece_sign_network_empty_config_base_{{ execution_date | date_add(1) | cst_ds }}',
    sql='spmi/dim/spmi/dim_piece_sign_network_empty_config_base/execute.sql',
    pool_slots=2,
    executor_cores=2,
    executor_memory='3G',
    num_executors=2,
    conf={'spark.dynamicAllocation.enabled': 'true',
          'spark.shuffle.service.enabled': 'true',
          'spark.dynamicAllocation.maxExecutors': 12,
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 30,
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',
          'spark.executor.memoryOverhead': '1G',
          'spark.yarn.maxAppAttempts': 1,
          },
    hiveconf={'hive.exec.dynamic.partition': 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode': 'nonstrict',
              'hive.exec.max.dynamic.partitions': 10,  # 最大分区
              'hive.exec.max.dynamic.partitions.pernode': 10,  # 最大分区
              },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=10),
    retries=0
)

spmi_dim__dim_piece_sign_network_empty_config_base << [spmi_ods__piece_sign_network_empty_config,
                                                       jms_dim__dim_network_whole_massage_check
                                                       ]
